﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace GBits.ContactManager
{
    public partial class frmSearchContacts : Form
    {

        private static frmSearchContacts _frmSearch = null;

        public static frmSearchContacts GetForm()
        {
            if (_frmSearch == null)
                _frmSearch = new frmSearchContacts();
            return _frmSearch;
        }

        private frmSearchContacts()
        {
            InitializeComponent();
        }

        private void frmSearchContacts_Load(object sender, EventArgs e)
        {

        }

        private void frmSearchContacts_FormClosed(object sender, FormClosedEventArgs e)
        {
            _frmSearch = null;
        }

        private void cbFName_CheckedChanged(object sender, EventArgs e)
        {
            tbFName.Enabled = cbFName.Checked;
        }

        private void cbMName_CheckedChanged(object sender, EventArgs e)
        {
            tbMName.Enabled = cbMName.Checked;
        }

        private void cbLName_CheckedChanged(object sender, EventArgs e)
        {
            tbLName.Enabled = cbLName.Checked;
        }

        private void cbOrgName_CheckedChanged(object sender, EventArgs e)
        {
            tbOrgName.Enabled = cbOrgName.Checked;
        }

        private void cbDepartment_CheckedChanged(object sender, EventArgs e)
        {
            tbOrgDepartment.Enabled = cbDepartment.Checked; 
        }

        private void cbOrgTitle_CheckedChanged(object sender, EventArgs e)
        {
            tbOrgTitle.Enabled = cbOrgTitle.Checked;
        }

        private void btnSearch_Click(object sender, EventArgs e)
        {
            List<Control> criteria = new List<Control>();
            foreach (Control c in gbSearch.Controls)
            {
                if (c is CheckBox && ((CheckBox)c).Checked)
                {
                    criteria.Add(c);
                }
            }

            List<Control> results = new List<Control>();
            foreach (Control c in gbResults.Controls)
            {
                if (c is CheckBox && ((CheckBox)c).Checked)
                {
                    results.Add(c);
                }
            }
            foreach (Control c in gbOrgResults.Controls)
            {
                if (c is CheckBox && ((CheckBox)c).Checked)
                {
                    results.Add(c);
                }
            }

        }


    }
}
